package com.itheima06;

import java.util.concurrent.ArrayBlockingQueue;

public class Test {

    public static void main(String[] args) {

        ArrayBlockingQueue<String> queue = new ArrayBlockingQueue<>(10);

        new Thread(() -> {

            while (true) {

                try {
                    queue.put("货物");
                    System.out.println("放了一个货物" + queue.size());
                } catch (InterruptedException e) {
                    e.printStackTrace();

                }
            }
        }).start();

        new Thread(() -> {

            while (true) {
                try {
                    System.out.println("拿了一个" + queue.take() + queue.size());
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }).start();


    }
}
